import {request} from '../utils/request.js'

const apiUrl = {
	openGoods:'/goods/addGoods',
	getGoodsDetail:'/goods/getGoodsDetail',
	reserveRole:'/goods/buy',
	getGoodsBuyStatus:'/goods/buy/getGoodsBuyStatus',
	getOrderDetail:'/order/getOrderDetail',
	
	getTruncationData:'/goodsTruncation/getTruncationData',
	getCreatorTruncationResult:'/goodsTruncation/getCreatorTruncationResult',
	truncationOnClick:'/goodsTruncation/truncationOnClick',
	updateGoodsTime:'/goods/updateGoodsTime',
	completeOrderOnClick:'/goodsTruncation/completeOrderOnClick',
	exportExcel:'/goodsTruncation/exportExcel'
}

export function openGoods(data) {
	return request(apiUrl.openGoods, 'POST', data)
}

export function getGoodsDetail(data) {
	return request(`${apiUrl.getGoodsDetail}?goodsId=${data}`, 'GET')
}

export function getOrderDetail(data) {
	return request(`${apiUrl.getOrderDetail}?orderId=${data}`, 'GET')
}

export function reserveRole(data) {
	return request(apiUrl.reserveRole, 'POST', data)
}

export function getTruncationData(data) {
	return request(`${apiUrl.getTruncationData}?goodsId=${data}`, 'GET')
}

export function getGoodsBuyStatus(data) {
	return request(apiUrl.getGoodsBuyStatus, 'GET',data)
}

export function getCreatorTruncationResult(data) {
	return request(apiUrl.getCreatorTruncationResult, 'GET',data)
}

export function truncationOnClick(data) {
	return request(`${apiUrl.truncationOnClick}?goodsId=${data.goodsId}&quantity=${data.quantity}`, 'PUT')
}

export function updateGoodsTime(data) {
	return request(apiUrl.updateGoodsTime, 'GET', data)
}

export function completeOrderOnClick(data) {
	return request(`${apiUrl.completeOrderOnClick}?goodsId=${data}`, 'PUT')
}

export function exportExcel(data) {
	return request(`${apiUrl.exportExcel}?goodsId=${data}`, 'GET')
}